import 'package:flutter/material.dart';
import 'dart:async';
import 'package:news_flutter/pages/user/login_page.dart';

class MyNavigator {
  static List<String> pagesOnlyLogin = [
    "UserCenterInfoPage",
    "NewsTypesManagePage",
  ];

  static Future<T> push<T extends Object>(BuildContext context, Widget page,
      {bool fullscreenDialog = false}) {
    //在此处理未登录时，页面处理
    String pageClass = "$page";
    bool isLogin = true;
    if (isLogin == false && pagesOnlyLogin.contains(pageClass)) {
      page = LoginPage();
      fullscreenDialog = true;
    }
    return Navigator.of(context).push(MaterialPageRoute(
        builder: (context) {
          return page;
        },
        fullscreenDialog: fullscreenDialog));
  }
}
